/*
 EasySinhala. An English to Sinhala translitratior.
 Copyright (C) 2009  S. Suhothayan

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

 this is a product by S.Suhothayan
 CSE
 University of Moratuwa
 */

easysinhala.ns(function() {
    with (easysinhala.LIB) {

        theApp.easysinhalaModule =
        {
            debug:true,
            totalText:'',
            tempText:'',
            text:'',
            space:true,
            Sinhala_on:false,        //shows whether easysinhala is enabled or not
            focusedElement:'',        // will have the currently focused element
            ctrlKey:false,
            altKey:false,
            tooltipTextDisplayLength:30,
            re1 : /\s[^\s]+\s$/g,                // to get the last word
            re2 : /\s[^\s]+$/g ,
            re3 : /^[^\s]*\s$/g,
            re4 : /^[^\s]*$/g,
            nVowels: 26,
            consonants:new Array(),
            consonantsUni: new Array(),
            vowels: new Array(),
            vowelsUni: new Array(),
            vowelModifiersUni: new Array(),
            specialConsonants: new Array(),
            specialConsonantsen: new Array(),
            specialConsonantsUni: new Array(),
            specialCharUni: new Array(),
            specialChar: new Array(),

            dump: function(aMessage) {
                //this.dump("es tooltipElement.value: " + tempq);
                if (this.debug) {
                    var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
                            .getService(Components.interfaces.nsIConsoleService);
                    consoleService.logStringMessage("EasySinhala: " + aMessage);
                }
            },
            init: function() {        //this will enable and disable easysinhala
                // addEventListener("click", this.hidePanelfunc, true);
                easysinhala.easysinhalaModule.initSinhala();
                if (this.Sinhala_on == false) {    //enabling
                    addEventListener("focus", this.focusedElementForTooltip, true);
                    addEventListener("keydown", this.TextStop, true);
                    addEventListener("keyup", this.focusedElementForTextReplace, true);
                    addEventListener("click", this.focusedElementForTooltipClick, true);
                    addEventListener("blur", this.hidetooltipfunc, true);

                    this.Sinhala_on = true;
                } else {                    //desabling
                    this.hidetooltipfunc();
                    removeEventListener("focus", this.focusedElementForTooltip, true);
                    removeEventListener("keydown", this.TextStop, true);
                    removeEventListener("keyup", this.focusedElementForTextReplace, true);
                    removeEventListener("click", this.focusedElementForTooltipClick, true);
                    // removeEventListener("click", this.hidePanelfunc, true);
                    removeEventListener("blur", this.hidetooltipfunc, true);

                    this.Sinhala_on = false;
                }
                document.getElementById("easysinhalaButton").setAttribute("state", (this.Sinhala_on ? "on" : "off"));			//will show the state of easysinhala at the UI
                document.getElementById("easysinhala-enabled").setAttribute("checked", (this.Sinhala_on ? "true" : "false"));
                document.getElementById("easysinhala-enabled1").setAttribute("checked", (this.Sinhala_on ? "true" : "false"));
                document.getElementById("easysinhala-enabled2").setAttribute("checked", (this.Sinhala_on ? "true" : "false"));
                document.getElementById("easysinhalaPanelIcon").setAttribute("state", (this.Sinhala_on ? "on" : "off"));
                document.getElementById("easysinhalaStatusbarIcon").setAttribute("state", (this.Sinhala_on ? "on" : "off"));

            },

            // to show the tool tip with the transliterated sinhala world///////////////////////////////
            focusedElementForTooltipClick: function(e) {
                easysinhala.easysinhalaModule.focusedElementForTooltip(e);
            },

            focusedElementForTooltip: function(e) {

                //this.focusedElement = document.commandDispatcher.focusedElement;

                this.focusedElement = e.target;

                if (this.focusedElement != null) {

                    var name;
                    if (this.focusedElement.localName)
                        name = this.focusedElement.localName.toUpperCase();//this line of code nores the password fields selections to be shown in the preview
                    var type = this.focusedElement.type;
                    //  this.dump(name);
                    if (name == "TEXTAREA" || name == "TEXTBOX" || name == "SEARCHBAR" || (name == "INPUT" && (type == "text" || type == "file")))//to avoid showing password fields content translated
                    {

                        var tooltip = document.getElementById("easysinhalaTooltip");
                        tooltip.openPopup(this.focusedElement, "before_start", 0, 0, false, true, e);
                        var tooltipElement = document.getElementById("easysinhalaTooltipValue");
                        tooltipElement.value = easysinhala.easysinhalaModule.showText(this.focusedElement, name);
                        this.dump("es tooltipElement.value: " + tooltipElement.value);
                    }
                }
            }
            ,

            showText: function(objElement, name) {        // to displaying the sample text _ tanslitriated
                this.dump("es name: " + name);
                if (this.Sinhala_on == true) {
                    var cursorPosition = easysinhala.easysinhalaModule.doGetCaretPosition(objElement);
                    this.dump("cp 1:" + cursorPosition);
                    this.totalText = objElement.value;
                    this.dump("es objElement.value: " + objElement.value);
                    var baforeCurser = this.totalText.substring(0, cursorPosition);
                    if (name == "SEARCHBAR") {

                        baforeCurser = this.totalText;
                        this.text = this.totalText;

                    }

                    this.tempText = baforeCurser.match(this.re1);

                    this.dump("es  baforeCurser: " + baforeCurser);
                    this.dump("es tempText1: " + this.tempText);
                    this.space = true;
                    if (this.tempText == null) {
                        this.tempText = baforeCurser.match(this.re2);
                        this.dump("es tempText2: " + this.tempText);
                        this.space = false;
                        if (this.tempText == null) {
                            this.tempText = baforeCurser.match(this.re3);
                            this.dump("es tempText3: " + this.tempText);
                            this.space = true;
                            if (this.tempText == null) {
                                this.tempText = baforeCurser.match(this.re4);
                                this.dump("es tempText4: " + this.tempText);
                                this.space = false;
                                if (this.tempText == null) {
                                    this.space = false;
                                    this.tempText = "";
                                }
                            }
                        }
                    }
                    this.text = this.tempText.toString();
                    this.dump("es text: " + this.tempText);
                    this.dump("es  this.text: a" + this.text + "a");

                    this.text = easysinhala.easysinhalaModule.translate(this.text);							// translitriating
                    this.dump("es  this.text: a" + this.text + "a");
                    if (this.space == true) {
                        return "";
                    } else {
                        if (this.text.length > this.tooltipTextDisplayLength) {

                            return "..." + this.text.substring(this.text.length - this.tooltipTextDisplayLength, this.text.length);
                        } else {
                            return this.text;
                        }
                    }
                } else
                    return "";
            }
            ,

            hidetooltipfunc: function() {    //hiding tooltip
                var tooltipElemant = document.getElementById("easysinhalaTooltip");
                tooltipElemant.hidePopup();
            }
            ,
            //end of showing tooltips

            //to replace the english words with the sinhala ones
            focusedElementForTextReplace: function(e) {        // gets the text fields
                var unicode = e.keyCode ? e.keyCode : e.charCode
                //var this.focusedElement = document.commandDispatcher.focusedElement;
                focusedElement = e.target;
                if (focusedElement != null) {
                    if (focusedElement.localName)
                        name = focusedElement.localName.toUpperCase();//this line of code igonores the password fields selections to be shown in the preview
                    var type = focusedElement.type;
                    if (name == "TEXTAREA" || name == "TEXTBOX" || name == "SEARCHBAR" || (name == "INPUT" && (type == "text" || type == "file")))//to avoid showing password fields content translated
                    {
                        var tooltipElemant = document.getElementById("easysinhalaTooltip");
                        tooltipElemant.openPopup(focusedElement, "before_start", 0, 0, false, true, e);
                        var tooltipElemantValue = document.getElementById("easysinhalaTooltipValue");
                        easysinhala.easysinhalaModule.cahangeText(e, focusedElement, tooltipElemantValue, name);
                    } else if (name != "INPUT") {
                        easysinhala.easysinhalaModule.hidetooltipfunc();
                        if ("48" <= unicode && unicode <= "57" || "65" <= unicode && unicode <= "90" || unicode == "32") {// enabling only for selected keys
                            if (!(this.altKey || this.ctrlKey)) {
                                if (e && e.preventDefault)             //prevent default action by keyboard
                                    e.preventDefault();
                                easysinhala.easysinhalaModule.showPenal(e, "false");
                            }
                        }
                    } else
                        this.hidetooltipfunc();
                }
                if (unicode == "17")     // control key
                    this.ctrlKey = false;
                if (unicode == "18")      // alt key
                    this.altKey = false;
            }
            ,

            cahangeText: function(e, objElement, tooltipObj, name) {    // to transliterate the word//not yet set
                if (this.Sinhala_on == true) {
                    this.space = false;
                    var unicode = e.keyCode ? e.keyCode : e.charCode
                    var enter = false;
                    var show = false;
                    if (unicode == "27") {
                        this.hidePanel();
                        this.hidetooltipfunc();
                    } else {
                        if (unicode == "32") {  // @ space
                            this.space = true;
                        } else if (unicode == "13") {
                            this.space = true;
                            enter = true;
                        } else if (unicode == "37" || unicode == "38" || unicode == "39" || unicode == "40") {    // not to transliterate when arrow keys are pressed
                            this.space = false;
                            show = true;
                        } else {
                            this.space = false;
                        }
                        var cursorPosition = easysinhala.easysinhalaModule.doGetCaretPosition(objElement);
                        this.totalText = objElement.value;
                        var baforeCurser = this.totalText.substring(0, cursorPosition);
                        var afterCurser = this.totalText.substring(cursorPosition);
                        this.dump("es cursorPosition: " + cursorPosition);
                        if (name == "SEARCHBAR") {
                            baforeCurser = this.totalText;
                            afterCurser = "";
                            // this.text = easysinhala.easysinhalaModule.translate(this.totalText);
                            // objElement.value =  this.text ;
                            // tooltipObj.value=   this.text ;
                        }

                        this.tempText = baforeCurser.match(this.re1);
                        this.dump("es this.tempTextq1: " + this.tempText);
                        var space1 = true;
                        if (this.tempText == null) {
                            this.tempText = baforeCurser.match(this.re2);
                            space1 = false;
                            this.dump("es this.tempTextq2: " + this.tempText);
                            if (this.tempText == null) {
                                this.tempText = baforeCurser.match(this.re3);
                                space1 = true;
                                this.dump("es this.tempTextq3: " + this.tempText);
                                if (this.tempText == null) {
                                    this.tempText = baforeCurser.match(this.re4);
                                    space1 = false;
                                    this.dump("es this.tempTextq4: " + this.tempText);
                                    if (this.tempText == null) {
                                        space1 = false;
                                        this.tempText = "";
                                    }
                                }
                            }
                        }
                        this.text = this.tempText.toString();
                        this.dump("es this.tempTextq5: " + this.tempText);
                        baforeCurser = baforeCurser.substring(0, baforeCurser.length - this.text.length);
                        this.text = easysinhala.easysinhalaModule.translate(this.text);

                        var baforeFinalCurser;
                        if (enter == true) {                            // setting all back after tracslitration
                            baforeFinalCurser = baforeCurser + this.text + "\u0085";
                        }
                        else {
                            baforeFinalCurser = baforeCurser + this.text;
                        }

                    }
                    if (show == true && space1 == true) {
                        tooltipObj.value = "";
                    } else {
                        if (this.space == true) {
                            objElement.value = baforeFinalCurser + afterCurser;
                            tooltipObj.value = "";
                            easysinhala.easysinhalaModule.setCaretPosition(objElement, baforeFinalCurser.length);
                        } else {
                            if (this.text.length > this.tooltipTextDisplayLength) {

                                tooltipObj.value = "..." + this.text.substring(this.text.length - this.tooltipTextDisplayLength, this.text.length);
                            } else {
                                tooltipObj.value = this.text;
                            }

                        }
                    }
                    //                    }
                    //                    }
                } else
                    tooltipObj.value = "";
            }
            ,
            //end of replacing the words

            //showing panels to not defiend fields

            TextStop: function(e) {        //to prevent default action by keyboard

                var unicode = e.keyCode ? e.keyCode : e.charCode
                if (unicode == "17")
                    this.ctrlKey = true;
                if (unicode == "18")
                    this.altKey = true;
                //var focusedElement = document.commandDispatcher.focusedElement;
                var focusedElement = e.target;
                while (focusedElement != null && focusedElement.nodeType != focusedElement.ELEMENT_NODE)
                    focusedElement = focusedElement.parentNode;
                if (focusedElement != null) {
                    if (focusedElement.localName)
                        name = focusedElement.localName.toUpperCase();//this line of code igonores the password fields selections to be shown in the preview

                    if (name == "TEXTAREA" || name == "TEXTBOX" || name == "SEARCHBAR" || name == "INPUT")//to avoid showing password fields content translated
                    {

                    } else {
                        easysinhala.easysinhalaModule.hidetooltipfunc();

                        if ("48" <= unicode && unicode <= "57" || "65" <= unicode && unicode <= "90" || unicode == "32") {// enabling only for selected keys
                            if (!(this.altKey || this.ctrlKey)) {
                                if (e && e.preventDefault)             //prevent default action by keyboard
                                    e.preventDefault();
                                easysinhala.easysinhalaModule.showPenal(e, "false");
                            }
                        }
                    }
                }
            }
            ,


            showPenal: function(e, str) {
                var panelfocusedElement = document.commandDispatcher.focusedElement;
                var x = 400;		//positon
                var y = 500;
                if (panelfocusedElement != null && str == "false") {
                    if (panelfocusedElement.tagName != "HTML") {     //not iframe
                        x = 0;
                        y = 0;
                    }
                }
                easysinhala.easysinhalaModule.hidetooltipfunc();
                var unicode = e.keyCode ? e.keyCode : e.charCode;
                if (("48" <= unicode && unicode <= "57" || "65" <= unicode && unicode <= "90" || unicode == "32" || unicode == "17" || unicode == "18") || str == "true") {// enabling only for selected keys
                    var tempTextanel = document.getElementById("easysinhalaPanel");
                    tempTextanel.openPopup(panelfocusedElement, "after_pointer", x, y, false, true, e);
                    var textboxPenel = document.getElementById("easysinhalaPopuptextbox");
                    //tempTextanel.focus();
                    textboxPenel.focus();
                    //textboxPenel.select();
                } else {
                    this.hidePanel();
                }
            }
            ,

            copyit: function() {                // to copy the text in the text area of the panel
                var penel = document.getElementById("easysinhalaPopuptextbox");
                penel.focus();
                textToCopy = penel.value;
                const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].
                        getService(Components.interfaces.nsIClipboardHelper);
                gClipboardHelper.copyString(textToCopy);
                easysinhala.easysinhalaModule.cleartext();
            }
            ,

            cleartext: function () {            // to clear the text in the text area of the panel
                var penel = document.getElementById("easysinhalaPopuptextbox");
                penel.value = "";
                this.hidePanel();
                this.hidetooltipfunc();
            }
            ,

            hidePanel: function () {        //hiding the panel
                //var focusedElement = document.commandDispatcher.focusedElement;
                var penel = document.getElementById("easysinhalaPanel");
                penel.hidePopup();
            }
            ,


            //end of showing panel/////////////////////////////////////////////////////////////

            // getting and setting Chareter Positions/////////////////////////////////////////////////

            setCaretPosition: function (focusedEliment, pos) { // setting the curser position within the text field
                // after trasliterating

                if (focusedEliment.setSelectionRange) {
                    focusedEliment.focus();
                    focusedEliment.setSelectionRange(pos, pos);
                }
                else if (focusedEliment.createTextRange) {
                    var range = focusedEliment.createTextRange();
                    range.collapse(true);
                    range.moveEnd('character', pos);
                    range.moveStart('character', pos);
                    range.select();
                }
            }
            ,

            doGetCaretPosition: function  (focusedElimentToGetPosi) {// getting the curser position within the text field
                var CaretPos = 0;
                // alert(focusedElimentToGetPosi+focusedElimentToGetPosi.localName+focusedElimentToGetPosi.type+focusedElimentToGetPosi);
                if (focusedElimentToGetPosi.selectionStart || focusedElimentToGetPosi.selectionStart == '0')
                    CaretPos = focusedElimentToGetPosi.selectionStart;
                return (CaretPos);
            }
            ,

            //end of getting and setting Chareter Positions/////////////////////////////////////////////////////

            //other  supporting feature functions////////////////////////////////////////////////////////////

            openURL: function(url) {    //to open the url on a new page
                if (window.delayedOpenTab)
                    window.delayedOpenTab(url)
                else
                    Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
                            .getService(Components.interfaces.nsIExternalProtocolService)
                            .loadUrl(this.url2uri(url));
            }            ,

            clickButten: function (e) {    //to check wheter ts right click or left
                var rightclick;
                if (!e)
                    var e = window.event;
                if (e.which)
                    rightclick = (e.which == 3);
                else if (e.button)
                    rightclick = (e.button == 2);
                if (rightclick == false)        //if left click toggle the state of easysinhala
                    easysinhala.easysinhalaModule.init();
            },

            //end of other  suporting feature functions////////////////////////////////////////////////////////////

            translate: function(text) {        // traslierating function
                //convert from sinhala to singlish
                var s = '';
                var r = '';
                var v = '';
                var counter = 0;


                //special consonents
                for (var i = 0; i < this.specialConsonantsen.length; i++) {
                    text = text.replace(this.specialConsonantsUni[i], this.specialConsonantsen[i]);
                }


                //consonents + special Chars
                for (var i = 0; i < this.specialCharUni.length; i++) {
                    for (var j = 0; j < this.consonants.length; j++) {
                        s = this.consonants[j] + this.specialChar[i];
                        v = this.consonantsUni[j] + this.specialCharUni[i];
                        r = new RegExp(v, "g");
                        text = text.replace(r, s);
                    }
                }

                //consonents + HAL
                for (var i = 0; i < this.consonants.length; i++) {
                    r = new RegExp(this.consonantsUni[i] + "\u0DCA", "g");
                    text = text.replace(r, this.consonants[i]);
                }

                //consonants + Rakaransha + vowel modifiers
                for (var j = 0; j < this.consonants.length; j++) {
                    for (var i = 0; i < this.vowels.length; i++) {
                        s = this.consonants[j] + "r" + this.vowels[i];
                        v = this.consonantsUni[j] + "\u0DCA\u200D\u0DBB" + this.vowelModifiersUni[i];
                        r = new RegExp(v, "g");
                        text = text.replace(r, s);
                    }
                    s = this.consonants[j] + "r";
                    v = this.consonantsUni[j] + "\u200D\u0DCA\u0DBB";
                    r = new RegExp(v, "g");
                    text = text.replace(r, s);
                }

                //consonents + vowel modifiers
                for (var i = 0; i < this.consonants.length; i++) {
                    for (var j = this.nVowels - 1; j >= 0; j--) {
                        s = this.consonants[i] + this.vowels[j];
                        v = this.consonantsUni[i] + this.vowelModifiersUni[j];
                        r = new RegExp(v, "g");
                        text = text.replace(r, s);
                    }
                }

                //vowels
                for (var i = 0; i < this.vowels.length; i++) {
                    r = new RegExp(this.vowelsUni[i], "g");
                    text = text.replace(r, this.vowels[i]);
                }

                //convert from singlish text to sinhala
                s = '';
                r = '';
                v = '';
                counter = 0;

                //special consonents
                for (var i = 0; i < this.specialConsonants.length; i++) {
                    text = text.replace(this.specialConsonants[i], this.specialConsonantsUni[i]);
                }
                //consonents + special Chars
                for (var i = 0; i < this.specialCharUni.length; i++) {
                    for (var j = 0; j < this.consonants.length; j++) {
                        s = this.consonants[j] + this.specialChar[i];
                        v = this.consonantsUni[j] + this.specialCharUni[i];
                        r = new RegExp(s, "g");
                        text = text.replace(r, v);
                    }
                }
                //consonants + Rakaransha + vowel modifiers
                for (var j = 0; j < this.consonants.length; j++) {
                    for (var i = 0; i < this.vowels.length; i++) {
                        s = this.consonants[j] + "r" + this.vowels[i];
                        v = this.consonantsUni[j] + "\u0DCA\u200D\u0DBB" + this.vowelModifiersUni[i];
                        r = new RegExp(s, "g");
                        text = text.replace(r, v);
                    }
                    s = this.consonants[j] + "r";
                    v = this.consonantsUni[j] + "\u200D\u0DCA\u0DBB";
                    r = new RegExp(s, "g");
                    text = text.replace(r, v);
                }
                //consonents + vowel modifiers
                for (var i = 0; i < this.consonants.length; i++) {
                    for (var j = 0; j < this.nVowels; j++) {
                        s = this.consonants[i] + this.vowels[j];
                        v = this.consonantsUni[i] + this.vowelModifiersUni[j];
                        r = new RegExp(s, "g");
                        text = text.replace(r, v);
                    }
                }

                //consonents + HAL
                for (var i = 0; i < this.consonants.length; i++) {
                    r = new RegExp(this.consonants[i], "g");
                    text = text.replace(r, this.consonantsUni[i] + "\u0DCA");
                }

                //vowels
                for (var i = 0; i < this.vowels.length; i++) {
                    r = new RegExp(this.vowels[i], "g");
                    text = text.replace(r, this.vowelsUni[i]);
                }

                return text;

            },
            initSinhala: function() {

                this.vowelsUni[0] = "\u0D8C";
                this.vowels[0] = 'oo';
                this.vowelModifiersUni[0] = "\u0DD6";
                this.vowelsUni[1] = "\u0D95";
                this.vowels[1] = 'oe';
                this.vowelModifiersUni[1] = "\u0DDD";
                this.vowelsUni[2] = "\u0D95";
                this.vowels[2] = 'o\\)';
                this.vowelModifiersUni[2] = "\u0DDD";
                this.vowelsUni[3] = "\u0D86";
                this.vowels[3] = 'aa';
                this.vowelModifiersUni[3] = "\u0DCF";
                this.vowelsUni[4] = "\u0D86";
                this.vowels[4] = 'a\\)';
                this.vowelModifiersUni[4] = "\u0DCF";
                this.vowelsUni[5] = "\u0D88";
                this.vowels[5] = 'Aa';
                this.vowelModifiersUni[5] = "\u0DD1";
                this.vowelsUni[6] = "\u0D88";
                this.vowels[6] = 'ae';
                this.vowelModifiersUni[6] = "\u0DD1";
                this.vowelsUni[7] = "\u0D88";
                this.vowels[7] = 'A\\)';
                this.vowelModifiersUni[7] = "\u0DD1";
                this.vowelsUni[8] = "\u0D8A";
                this.vowels[8] = 'ii';
                this.vowelModifiersUni[8] = "\u0DD3";
                this.vowelsUni[9] = "\u0D8A";
                this.vowels[9] = 'ie';
                this.vowelModifiersUni[9] = "\u0DD3";
                this.vowelsUni[10] = "\u0D8A";
                this.vowels[10] = 'ee';
                this.vowelModifiersUni[10] = "\u0DD3";
                this.vowelsUni[11] = "\u0D8A";
                this.vowels[11] = 'i\\)';
                this.vowelModifiersUni[11] = "\u0DD3";
                this.vowelsUni[12] = "\u0D92";
                this.vowels[12] = 'ea';
                this.vowelModifiersUni[12] = "\u0DDA";
                this.vowelsUni[13] = "\u0D92";
                this.vowels[13] = 'ei';
                this.vowelModifiersUni[13] = "\u0DDA";
                this.vowelsUni[14] = "\u0D92";
                this.vowels[14] = 'e\\)';
                this.vowelModifiersUni[14] = "\u0DDA";
                this.vowelsUni[15] = "\u0D8C";
                this.vowels[15] = 'uu';
                this.vowelModifiersUni[15] = "\u0DD6";
                this.vowelsUni[16] = "\u0D8C";
                this.vowels[16] = 'u\\)';
                this.vowelModifiersUni[16] = "\u0DD6";
                this.vowelsUni[17] = "\u0D96";
                this.vowels[17] = 'au';
                this.vowelModifiersUni[17] = "\u0DDE";
                this.vowelsUni[18] = "\u0D87";
                this.vowels[18] = '\\\\a';
                this.vowelModifiersUni[18] = "\u0DD0";
                this.vowelsUni[19] = "\u0D85";
                this.vowels[19] = 'a';
                this.vowelModifiersUni[19] = "";
                this.vowelsUni[20] = "\u0D87";
                this.vowels[20] = 'A';
                this.vowelModifiersUni[20] = "\u0DD0";
                this.vowelsUni[21] = "\u0D89";
                this.vowels[21] = 'i';
                this.vowelModifiersUni[21] = "\u0DD2";
                this.vowelsUni[22] = "\u0D91";
                this.vowels[22] = 'e';
                this.vowelModifiersUni[22] = "\u0DD9";
                this.vowelsUni[23] = "\u0D8B";
                this.vowels[23] = 'u';
                this.vowelModifiersUni[23] = "\u0DD4";
                this.vowelsUni[24] = "\u0D94";
                this.vowels[24] = 'o';
                this.vowelModifiersUni[24] = "\u0DDC";
                this.vowelsUni[25] = "\u0D93";
                this.vowels[25] = 'I';
                this.vowelModifiersUni[25] = "\u0DDB";

                this.specialConsonantsUni[0] = "\u0D82";
                this.specialConsonants[0] = /\\n/g;
                this.specialConsonantsen[0] = "\\n";
                this.specialConsonantsUni[1] = "\u0D83";
                this.specialConsonants[1] = /\\h/g;
                this.specialConsonantsen[1] = "\\h";
                this.specialConsonantsUni[2] = "\u0D9E";
                this.specialConsonants[2] = /\\N/g;
                this.specialConsonantsen[2] = "\\N";
                this.specialConsonantsUni[3] = "\u0D8D";
                this.specialConsonants[3] = /\\R/g;
                this.specialConsonantsen[3] = "\\R";
                this.specialConsonantsUni[4] = "\u0DBB\u0DCA" + "\u200D";
                this.specialConsonants[4] = /R/g;
                this.specialConsonantsUni[5] = "\u0DBB\u0DCA" + "\u200D";
                this.specialConsonants[5] = /\\r/g;

                this.consonantsUni[0] = "\u0DAC";
                this.consonants[0] = 'nnd';
                this.consonantsUni[1] = "\u0DB3";
                this.consonants[1] = 'nndh';
                this.consonantsUni[2] = "\u0D9F";
                this.consonants[2] = 'nng';
                this.consonantsUni[3] = "\u0DAE";
                this.consonants[3] = 'Th';
                this.consonantsUni[4] = "\u0DB0";
                this.consonants[4] = 'Dh';
                this.consonantsUni[5] = "\u0DA5";
                this.consonants[5] = 'GN';
                this.consonantsUni[6] = "\u0DA1";
                this.consonants[6] = 'Ch';
                this.consonantsUni[7] = "\u0DB5";
                this.consonants[7] = 'ph';
                this.consonantsUni[8] = "\u0DB7";
                this.consonants[8] = 'bh';
                this.consonantsUni[9] = "\u0DC1";
                this.consonants[9] = 'sh';
                this.consonantsUni[10] = "\u0DC2";
                this.consonants[10] = 'Sh';
                this.consonantsUni[11] = "\u0D9D";
                this.consonants[11] = 'G';
                this.consonantsUni[12] = "\u0DA4";
                this.consonants[12] = 'KN';
                this.consonantsUni[13] = "\u0DA3";
                this.consonants[13] = 'Jh';
                this.consonantsUni[14] = "\u0DAF";
                this.consonants[14] = 'dh';
                this.consonantsUni[15] = "\u0DA0";
                this.consonants[15] = 'ch';
                this.consonantsUni[16] = "\u0D9B";
                this.consonants[16] = 'K';
                this.consonantsUni[17] = "\u0DAD";
                this.consonants[17] = 'th';
                this.consonantsUni[18] = "\u0DA7";
                this.consonants[18] = 't';
                this.consonantsUni[19] = "\u0D9B";
                this.consonants[19] = 'kh';
                this.consonantsUni[20] = "\u0DA9";
                this.consonants[20] = 'd';
                this.consonantsUni[21] = "\u0DB1";
                this.consonants[21] = 'n';
                this.consonantsUni[22] = "\u0DB4";
                this.consonants[22] = 'p';
                this.consonantsUni[23] = "\u0DB6";
                this.consonants[23] = 'b';
                this.consonantsUni[24] = "\u0DB8";
                this.consonants[24] = 'm';
                this.consonantsUni[25] = "\u200D\u0DBA";
                this.consonants[25] = 'Y';
                this.consonantsUni[26] = "\u200D\u0DBA";
                this.consonants[26] = '\\u005C' + 'y';
                this.consonantsUni[27] = "\u0DBA";
                this.consonants[27] = 'y';
                this.consonantsUni[28] = "\u0DA2";
                this.consonants[28] = 'j';
                this.consonantsUni[29] = "\u0DBD";
                this.consonants[29] = 'l';
                this.consonantsUni[30] = "\u0DC0";
                this.consonants[30] = 'v';
                this.consonantsUni[31] = "\u0DC0";
                this.consonants[31] = 'w';
                this.consonantsUni[32] = "\u0DC3";
                this.consonants[32] = 's';
                this.consonantsUni[33] = "\u0DC4";
                this.consonants[33] = 'h';
                this.consonantsUni[34] = "\u0DAB";
                this.consonants[34] = 'N';
                this.consonantsUni[35] = "\u0DC5";
                this.consonants[35] = 'L';
                this.consonantsUni[36] = "\u0D9A";
                this.consonants[36] = 'k';
                this.consonantsUni[37] = "\u0D9D";
                this.consonants[37] = 'gh';
                this.consonantsUni[38] = "\u0DA8";
                this.consonants[38] = 'T';
                this.consonantsUni[39] = "\u0DAA";
                this.consonants[39] = 'D';
                this.consonantsUni[40] = "\u0DB5";
                this.consonants[40] = 'P';
                this.consonantsUni[41] = "\u0DB9";
                this.consonants[41] = 'B';
                this.consonantsUni[42] = "\u0DC6";
                this.consonants[42] = 'f';
                this.consonantsUni[43] = "\u0D9C";
                this.consonants[43] = 'g';
                this.consonantsUni[44] = "\u0DBB";
                this.consonants[44] = 'r';

                this.specialCharUni[0] = "\u0DF2";
                this.specialChar[0] = 'ruu';
                this.specialCharUni[1] = "\u0DD8";
                this.specialChar[1] = 'ru';
            }
        }

    }
});
